﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using TrainingCenterSystem;
using TrainingCenterSystem.UserManagement;


namespace TrainingCenterSystem.TestManagement
{
    public class IndividualTest
    {
        #region private members
        private string _id;
        private string _testid;
        private User _testPerson;
        private List<TestQuestion> _testQuestions;
        private List<TestAnswer> _testAnswers;
        #endregion

        #region setters and getters
        /// <summary>
        /// Gets or sets the ID of the individual test
        /// </summary>
        public string ID
        {
            get { return _id; }
            set { _id = value; }
        }

        /// <summary>
        /// Gets or sets the ID of the original test/vocabulary training
        /// </summary>
        public string TestID
        {
            get { return _testid; }
            set { _testid = value; }
        }

        /// <summary>
        /// Gets or sets the the test person, i.e. the person who takes the test
        /// </summary>
        public User TestPerson
        {
            get { return _testPerson; }
            set { _testPerson = value; }
        }

        /// <summary>
        /// Gets or sets the list of test questions
        /// </summary>
        public List<TestQuestion> TestQuestions
        {
            get { return _testQuestions; }
            set { _testQuestions = value; }
        }

        /// <summary>
        /// Gets or sets the the list of test answers
        /// </summary>
        public List<TestAnswer> TestAnswers
        {
            get { return _testAnswers; }
            set { _testAnswers = value; }
        }
        #endregion

        #region constructors
        /// <summary>
        /// Creates an object of IndividualTest
        /// </summary>
        /// <param name="testID">the ID of the owning/original test</param>
        /// <param name="aTestPerson">the person who takes the test</param>
        /// <param name="questions">the list of questions</param>
        public IndividualTest(string testID, User aTestPerson, List<TestQuestion> questions)
        {
            _id = "000";
            _testid = testID;
            _testPerson = aTestPerson;
            _testQuestions = questions;
            _testAnswers = new List<TestAnswer>();
            for (int i = 0; i < _testQuestions.Count; i++)            
                _testAnswers.Add(new TestAnswer(i.ToString(),i.ToString(),null));
            
        }
        #endregion

        #region methods
        /// <summary>
        /// Adds an answer to the IndividualTest object
        /// </summary>
        /// <param name="questionID">the questionID</param>
        /// <param name="answerText">the answer text</param>
        public void AddAnswer(string questionID, string answerText)
        {
            _testAnswers[Convert.ToInt32(questionID)].AnswerText = answerText;
        }
        #endregion
    }
}
